---
title: Environment Variables
description: A comprehensive reference of all environment variables that can be used to configure and control Nx behavior in different environments.
sidebar:
  order: 6
filter: 'type:References'
---

## Nx Environment Variables

The following environment variables are ones that you can set to change the behavior of Nx in different environments.

| Property                           | Type           | Description                                                                                                                                                                                                                         |
| ---------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NX_ADD_PLUGINS`                   | boolean        | If set to `false`, Nx will not add plugins to infer tasks. This is `true` by default. Workspaces created before Nx 18 will have this disabled via a migration for backwards compatibility                                           |
| `NX_BASE`                          | string         | The default base branch to use when calculating the affected projects. Can be overridden on the command line with `--base`.                                                                                                         |
| `NX_CACHE_DIRECTORY`               | string         | The cache for task outputs is stored in `.nx/cache` by default. Set this variable to use a different directory.                                                                                                                     |
| `NX_CACHE_PROJECT_GRAPH`           | boolean        | If set to `false`, disables the project graph cache. Most useful when developing a plugin that modifies the project graph.                                                                                                          |
| `NX_DAEMON`                        | boolean        | If set to `false`, disables the Nx daemon process. Disable the daemon to print `console.log` statements in plugin code you are developing.                                                                                          |
| `NX_DEFAULT_PROJECT`               | string         | The default project used for commands which require a project. e.g. `nx build`, `nx g component`, etc.                                                                                                                              |
| `NX_HEAD`                          | string         | The default head branch to use when calculating the affected projects. Can be overridden on the command line with `--head`.                                                                                                         |
| `NX_PERF_LOGGING`                  | boolean        | If set to `true`, will print debug information useful for profiling executors and Nx itself                                                                                                                                         |
| `NX_PROFILE`                       | string         | Prepend `NX_PROFILE=profile.json` before running targets with Nx to generate a file that be [loaded in Chrome dev tools](/docs/troubleshooting/performance-profiling) to visualize the performance of Nx across multiple processes. |
| `NX_WORKSPACE_DATA_DIRECTORY`      | string         | The project graph cache and some other internal nx caches are stored in `.nx/workspace-data` by default. Set this variable to use a different directory.                                                                            |
| `NX_PARALLEL`                      | number         | The number of tasks Nx should run in parallel. Overrides any configured value inside nx.json                                                                                                                                        |
| `NX_RUNNER`                        | string         | The name of task runner from the config to use. Can be overridden on the command line with `--runner`. Not read if `NX_TASKS_RUNNER` is set.                                                                                        |
| `NX_SKIP_NX_CACHE`                 | boolean        | Rerun the tasks even when the results are available in the cache.                                                                                                                                                                   |
| `NX_DISABLE_NX_CACHE`              | boolean        | Rerun the tasks even when the results are available in the cache.                                                                                                                                                                   |
| `NX_SKIP_REMOTE_CACHE`             | boolean        | Disable all remote caching features. This means that the remote cache will not be read from or written to. Includes Nx Cloud and self-hosted caches.                                                                                |
| `NX_DISABLE_REMOTE_CACHE`          | boolean        | Disable all remote caching features. This means that the remote cache will not be read from or written to. Includes Nx Cloud and self-hosted caches.                                                                                |
| `NX_TASKS_RUNNER`                  | string         | The name of task runner from the config to use. Can be overridden on the command line with `--runner`. Preferred over `NX_RUNNER`.                                                                                                  |
| `NX_TASKS_RUNNER_DYNAMIC_OUTPUT`   | boolean        | If set to `false`, will use non-dynamic terminal output strategy (what you see in CI), even when you terminal can support the dynamic version                                                                                       |
| `NX_TUI`                           | boolean        | If set to `true` or `false`, will enable or disable the Terminal UI (TUI) for running tasks. TUI provides an interactive visual interface for task execution                                                                        |
| `NX_TUI_AUTO_EXIT`                 | boolean/number | Controls whether the TUI automatically exits after tasks finish. If `true`, exits immediately. If `false`, never exits automatically. If a number, shows a countdown for that many seconds before exiting                           |
| `NX_VERBOSE_LOGGING`               | boolean        | If set to `true`, will print debug information useful for troubleshooting                                                                                                                                                           |
| `NX_DRY_RUN`                       | boolean        | If set to `true`, will perform a dry run of the generator. No files will be created and no packages will be installed.                                                                                                              |
| `NX_INTERACTIVE`                   | boolean        | If set to `true`, will allow Nx to prompt you in the terminal to answer some further questions when running generators.                                                                                                             |
| `NX_GENERATE_QUIET`                | boolean        | If set to `true`, will prevent Nx logging file operations during generate                                                                                                                                                           |
| `NX_PREFER_TS_NODE`                | boolean        | If set to `true`, Nx will use `ts-node` for local execution of plugins even if `@swc-node/register` is installed.                                                                                                                   |
| `NX_IGNORE_CYCLES`                 | boolean        | If set to `true`, Nx will ignore errors created by a task graph circular dependency. Can be overridden on the command line with `--nxIgnoreCycles`                                                                                  |
| `NX_BATCH_MODE`                    | boolean        | If set to `true`, Nx will run task(s) in batches for executors which support batches.                                                                                                                                               |
| `NX_SKIP_LOG_GROUPING`             | boolean        | If set to `true`, Nx will not group command's logs on CI.                                                                                                                                                                           |
| `NX_MIGRATE_CLI_VERSION`           | string         | The version of Nx to use for running the `nx migrate` command. If not set, it defaults to `latest`.                                                                                                                                 |
| `NX_MIGRATE_SKIP_REGISTRY_FETCH`   | boolean        | If set to `true`, will skip fetching metadata from the registry and instead use the installation method directly.                                                                                                                   |
| `NX_LOAD_DOT_ENV_FILES`            | boolean        | If set to 'false', Nx will not load any environment files (e.g. `.local.env`, `.env.local`)                                                                                                                                         |
| `NX_MAX_CACHE_SIZE`                | string         | Alternative to configuring `maxCacheSize` in `nx.json`. Defines the maximum size of the local task cache. See [`maxCacheSize`](/docs/reference/nx-json#max-cache-size) for supported units and behavior details.                    |
| `NX_NATIVE_FILE_CACHE_DIRECTORY`   | string         | The cache for native `.node` files is stored under a global temp directory by default. Set this variable to use a different directory. This is interpreted as an absolute path.                                                     |
| `NX_PLUGIN_NO_TIMEOUTS`            | boolean        | If set to `true`, plugin operations will not timeout                                                                                                                                                                                |
| `NX_FORMAT_SORT_TSCONFIG_PATHS`    | boolean        | If set to `true`, generators will sort the TypeScript path mappings in the root tsconfig file.                                                                                                                                      |
| `NX_SKIP_VSCODE_EXTENSION_INSTALL` | boolean        | If set to `true`, skips the automatic installation of the Nx Console extension for supported editors. Set this in environments where the temp file that we store this information in otherwise isn't accessible.                    |

Nx will set the following environment variables so they can be accessible within the process even outside of executors and generators.

| Property                       | Type    | Description                                                                                                                                               |
| ------------------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NX_TASK_TARGET_PROJECT`       | string  | Set to the project name of the task being run. Use this to tell which project is being run.                                                               |
| `NX_TASK_TARGET_TARGET`        | string  | Set to the target name of the task being run. Use this to tell which target of the project is being run.                                                  |
| `NX_TASK_TARGET_CONFIGURATION` | string  | Set to the configuration name of the task being run. Use this to tell which configuration of the target is being run.                                     |
| `NX_GRAPH_CREATION`            | boolean | Set to `true` during the graph creation process. Use this to have inference plugins run different code during graph creation versus during task execution |
| `NX_DRY_RUN`                   | boolean | Set to `true` during dry runs of generators. Use this to avoid side effects during generators.                                                            |
| `NX_INTERACTIVE`               | boolean | Set to `false` when running generators with `--interactive=false`. Use this to prevent prompting during generators                                        |

## Nx Cloud Environment Variables

The following environment variables are specific to Nx Cloud and can be used to configure cloud-specific behavior:

{% aside type="tip" title="Verbose Logging" %}
Similar to the Nx CLI, Nx Cloud also used the `NX_VERBOSE_LOGGING` environment variable to output debug information
{% /aside %}

| Property                             | Type    | Description                                                                                                                                                                                                            |
| ------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NX_BRANCH`                          | string  | The current branch name. For most CI providers, `nx-cloud` determines this automatically. Must be set to the PR number for GitHub, BitBucket and GitLab integrations to work properly.                                 |
| `NX_CLOUD_ENABLE_METRICS_COLLECTION` | boolean | Enables collection of CPU and memory metrics during task execution. Currently opt-in, but will be enabled by default in future Nx versions. See [Task Resource Usage](/docs/guides/nx-cloud/ci-resource-usage).        |
| `NX_CLOUD_METRICS_DIRECTORY`         | string  | Directory where Nx writes resource metrics during task execution. See [Task Resource Usage](/docs/guides/nx-cloud/ci-resource-usage).                                                                                  |
| `NX_CI_EXECUTION_ID`                 | string  | A unique identifier for the current CI run or job. For most CI providers, `nx-cloud` determines this automatically. The value on the main job must match the value on all agents.                                      |
| `NX_CI_EXECUTION_ENV`                | string  | Used when you have multiple main jobs (e.g., running CI on both Linux and Windows). The main job with this env variable will connect to agents with the same env name.                                                 |
| `NX_AGENT_LAUNCH_TEMPLATE`           | string  | Should only be used when running agents with Manual DTE. Attaches a launch template type to your agents to leverage assignment rules for task distribution.                                                            |
| `NX_CLOUD_ACCESS_TOKEN`              | string  | Configure the Nx Cloud access token. Takes precedence over the `accessToken` property in `nx.json`. Common to have a read-only token in `nx.json` and a read-write token set via this environment variable in CI.      |
| `NX_CLOUD_API`                       | string  | The URL of the Nx Cloud instance to connect to. Overrides `nxCloudUrl` in `nx.json`.                                                                                                                                   |
| `NX_CLOUD_ENCRYPTION_KEY`            | string  | Enable end-to-end encryption of artifacts. Artifacts will be encrypted/decrypted on your machine. Can also be set via the `encryptionKey` property in `nx.json`.                                                       |
| `NX_CLOUD_NO_TIMEOUTS`               | boolean | Disables the default 10-second timeout for Nx Cloud requests.                                                                                                                                                          |
| `NX_NO_CLOUD`                        | boolean | If set to `true`, prevents Nx Cloud from being used for the current run. No remote cache will be used. Value cannot be set if using [distributed task execution](/docs/features/ci-features/distribute-task-execution) |
| `NX_VERBOSE_LOGGING`                 | boolean | Outputs debug information about agents communicating with the main job. Useful for debugging cache misses and on-premises setup issues.                                                                                |

### Deprecated Nx Cloud Environment Variables

| Property                                                | Type    | Description                                                                                                                                  |
| ------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `NX_RUN_GROUP`                                          | string  | Older versions of `nx-cloud` used this instead of `NX_CI_EXECUTION_ID` and `NX_CI_EXECUTION_ENV`. Served the same purpose.                   |
| `NX_CLOUD_DISTRIBUTED_EXECUTION_STOP_AGENTS_ON_FAILURE` | boolean | When set to `true`, tells Nx Cloud to stop agents if a command fails. Use `npx nx-cloud start-ci-run --stop-agents-on-failure=true` instead. |
| `NX_CLOUD_DISTRIBUTED_EXECUTION`                        | boolean | When set to `false`, disables distributed task execution. Use `--no-dte` or `--no-agents` flags instead.                                     |
